gh-132108: Add Buffer Protocol support to int.from_bytes to improve performance (#132109)#121
Closed
gh-132108: Add Buffer Protocol support to int.from_bytes to improve performance (#132109)#121
Conversation
…rove performance (python#132109) Speed up conversion from `bytes-like` objects like `bytearray` while keeping conversion from `bytes` stable. Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
…PORTED_SYMBOL, Py_LOCAL_SYMBOL,Py_IMPORTED_SYMBOL) (pythonGH-143508) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
The behaviour of Cut in nested parentheses, Repeat, Opt, and similar is somewhat chaotic. Apparently even the academic papers on PEG aren't as clear as they could be. And it doesn't really matter. Python only uses top-level cuts. When that changes, we can clarify as much as necessary (and even change the implementation to make sense for what we'll need). Document that this is deliberately unspecified, and add a test to make sure any decision is deliberate, tested and documented.
…cs/ignored_c_api.txt` is changed (pythonGH-143583)
…thon#143765) Modifies the test skip for unlimited stack size to add Emscripten to the exclusion list.
…PI (pythonGH-143568) pythongh-141004: Document old provisional names for vectorcall & code API For vectorcall API, the underscore-prefixed provisional names continue to be available per PEP 590: https://peps.python.org/pep-0590/#finalizing-the-api Use `versionadded`, `versionchanged`, and `:no-typesetting:` to mark this up. For PyCode API, use `:no-typesetting:` rather than `index::` so that these are semantically documented as C functions.
…ythonGH-132715) Writing out an object may involve a slot lookup, which is not safe to do with an exception raised. In debug mode an assertion failure will occur if this happens.
…ythonGH-143126) * Stronger check for recursive traces * Add a stop_tracing field * Stop early when tracing exceptions
…nd base64.b64encode() (pythonGH-143216)
…1634) Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
…H-143076) Add the unicodedata.iter_graphemes() function to iterate over grapheme clusters according to rules defined in Unicode Standard Annex #29. Add unicodedata.grapheme_cluster_break(), unicodedata.indic_conjunct_break() and unicodedata.extended_pictographic() functions to get the properties of the character which are related to the above algorithm. Co-authored-by: Guillaume "Vermeille" Sanchez <guillaume.v.sanchez@gmail.com>
…lasses (pythonGH-21480) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
…thon#144495) Replace a confusing error message with one that actually explains what the error is in `_overlapped.BindLocal()`. Fixes: python#144493
…on#144488) Use license directly from Modules/expat/COPYING. Co-authored-by: Victor Stinner <vstinner@python.org>
…ythonGH-144471) - Group the macros - Roughly order them to put the most important ones first - Add expansions where it makes sense; especially if there's an equivalent in modern C or a common compiler Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* Docs: module pages should not link to themselves * fix header punctuation
…ythongh-144332) Add `_Py_type_getattro_stackref`, a variant of type attribute lookup that returns `_PyStackRef` instead of `PyObject*`. This allows returning deferred references in the free-threaded build, reducing reference count contention when accessing type attributes. This significantly improves scaling of namedtuple instantiation across multiple threads. * Add blurb * Rename PyObject_GetAttrStackRef to _PyObject_GetAttrStackRef * Apply suggestion from @vstinner Co-authored-by: Victor Stinner <vstinner@python.org> * Apply suggestion from @vstinner Co-authored-by: Victor Stinner <vstinner@python.org> * format * Update Include/internal/pycore_function.h Co-authored-by: Victor Stinner <vstinner@python.org> --------- Co-authored-by: Victor Stinner <vstinner@python.org>
…thonGH-102753) Add Ascii85, Base85, and Z85 encoders and decoders to binascii, replacing the existing pure Python implementations in base64. This makes the codecs two orders of magnitude faster and consume two orders of magnitude less memory. Note that attempting to decode Ascii85 or Base85 data of length 1 mod 5 (after accounting for Ascii85 quirks) now produces an error, as no encoder would emit such data. This should be the only significant externally visible difference compared to the old implementation. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…-144479) Fix thread-safety issues when accessing frame attributes while another thread is executing the frame: - Add critical section to frame_repr() to prevent races when accessing the frame's code object and line number - Add _Py_NO_SANITIZE_THREAD to PyUnstable_InterpreterFrame_GetLasti() to allow intentional racy reads of instr_ptr. - Fix take_ownership() to not write to the original frame's f_executable
…ythongh-144524) When the interpreter is in a stop-the-world pause, critical sections don't need to acquire locks since no other threads can be running. This avoids a potential deadlock where lock fairness hands off ownership to a thread that has already suspended for stop-the-world.
…144544) Upgrade to VS 2026 on Windows tailcall CI
…formance of `importlib.metadata.Prepared.normalized` (python#144083) Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
…er() (python#140574) * pythongh-140281: Doc: Update free-threading how-to * pythongh-140281: Doc: Update free-threading how-to * Fix trailing whitespace * doc fixing of the cpython fixes#84116 * Docs: Document help and aliases for argparse.add_parser() (pythongh-84116) * Docs: Document help and aliases for argparse.add_parser() (pythongh-84116) * Fix trailing whitespace * Fix trailing whitespace * Fix trailing whitespace * Fix trailing whitespace * Fix trailing whitespace * Fix trailing whitespace * Fix trailing errors * Fix trailing errors and spaces * Fix docutils formatting, NEWS ref, and trailing whitespace * Docs: Update argparse.rst and add NEWS entry * Delete Doc/howto/free-threading-python.rst * Delete Misc/NEWS.d/next/Documentation/2025-10-25-00-49-43.gh-issue-140281.tuMQUe.rst * adding the depreceated tag * The error indexing was fixed * Fix trailing whitespace * Restore missing free-threading documentation * fixing some minor error * fixing some minor error part 2 * fixing some minor error part 3 * Fix NEWS entry format * Final cleanup of NEWS entry format 2 * changes in the argparse.rst * Remove unnecessary NEWS entry * Fixing the issue as requested * Added the Changes done before. * done the changes * done the changes#1 * Apply suggestion from @picnixz Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Apply suggestion from @picnixz Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Done the changes * Done the new changes * The versionadded is rectified * Update Doc/library/argparse.rst Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> * Docs editing * Docs fixing whitespace * Docs rectifiying * little bit rectification * Indentation rectification * Indentation rectification 1 * Apply suggestion from @picnixz Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * deprecated rectification * Remove mistakenly added NEWS entry * Update Doc/library/argparse.rst Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * changes #1 Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Update Doc/library/argparse.rst 2 Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * removed useless thing Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * changed according to the request Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Updated the test part --------- Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Upgrade bundled pip to 26.0.1
…gs from ctypes
When _ctypes is imported, it may call dlopen on the libpython shared
library, causing the dynamic linker to load a second mapping of the
library into the process address space. The remote debugging code
iterates memory regions from low addresses upward and returns the first
mapping whose filename matches libpython. After _ctypes is imported, it
finds the dlopen'd copy first, but that copy's PyRuntime section was
never initialized, so reading debug offsets from it fails.
Fix this by adding an optional cookie validation parameter to the
search_*_map_for_section functions. When a non-NULL cookie is provided,
each candidate address is validated by reading the first N bytes from
the remote process and comparing against the expected cookie. Candidates
that fail validation (e.g. uninitialized duplicate mappings from dlopen)
are skipped, allowing the search to continue to the real mapping.
The PyRuntime search passes _Py_Debug_Cookie ("xdebugpy") for validation,
while the AsyncioDebug search passes NULL (no validation needed).
https://claude.ai/code/session_01PAfGNYfkqzWePF2ejbJHNo
Replace the cookie/cookie_size parameter pair in search_*_map_for_section functions with an optional section_validator_t callback. This makes the search functions agnostic to the validation strategy while keeping the same behavior: PyRuntime searches pass _Py_RemoteDebug_ValidatePyRuntimeCookie, AsyncioDebug searches pass NULL (no validation needed). https://claude.ai/code/session_01PAfGNYfkqzWePF2ejbJHNo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Speed up conversion from
bytes-likeobjects likebytearraywhilekeeping conversion from
bytesstable.Co-authored-by: Sergey B Kirpichev skirpichev@gmail.com
Co-authored-by: Victor Stinner vstinner@python.org
📚 Documentation preview 📚: https://cpython-previews--121.org.readthedocs.build/